package com.autoTools.controller;


import java.util.HashMap;
import java.util.Map;

import org.jdom.Element;

import com.autoTools.util.BuildViewUtil;
import com.autoTools.util.Constants;
import com.autoTools.util.LogUtil;
import com.autoTools.util.XMLOper;
import com.autoTools.view.BaseView;
import com.autoTools.view.ShareViewList;
import com.autoTools.view.TableView;


public class BuildViewController extends BaseController
{
	final static String TAG = "LuncherController";
	
	public Object BuildViewCommand(Object ...params){
		LogUtil.sysLog(TAG,"BuildViewCommand");
		String cfgPath;
		if(params != null){
			cfgPath = (String)params[0];
			XMLOper parse = new XMLOper();
			Element root = parse.readFromFile(cfgPath);
			if(root != null){
				LogUtil.sysLog(TAG,"parse config file success");
				BuildViewUtil.buildViews(null,root);
				BuildViewFinisCommand();
			}else{
				LogUtil.sysLog(TAG,"parse config file final");
			}
		}
		return null;
	}
	
	public Object BuildViewFinisCommand(Object ...params){
		LogUtil.sysLog(TAG,"BuildViewFinisCommand");
		BaseView treeView = ShareViewList.getInstance().getView("TreeView");
		String[] strs = new String[2];
		strs[0]="root";
		strs[1]="china";
		treeView.addItem(strs);
		strs[0]="root";
		strs[1]="america";
		treeView.addItem(strs);
		strs[0]="china";
		strs[1]="beijing";
		treeView.addItem(strs);
		strs[0]="china";
		strs[1]="shanghai";
		treeView.addItem(strs);
		strs[0]="china";
		strs[1]="guangzhou";
		treeView.addItem(strs);
		strs[0]="china";
		strs[1]="shenzhen";
		treeView.addItem(strs);
		
		
		TableView tableView = (TableView)ShareViewList.getInstance().getView("TableView");
		tableView.addItem("tab1","name","val");
		tableView.addItem("tab2","name","val");
		tableView.addItem("tab3","name","val");
		tableView.addItem("tab4","name","val");
		tableView.addItem("tab5","name","val");
		return null;
	}
}
